import Cookies from "js-cookie";

const TokenKey = "X-Litemall-Admin-Token";

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function setIsAdmin(admin) {
  return Cookies.set("isAdmin", admin);
}

export function getIsAdmin() {
  let res = Cookies.get("isAdmin");
  if(res === 'true') {
    return true;
  } else {
    return false;
  }
}

export function resetIsAdmin() {
  return Cookies.set("isAdmin", false);
}
